package xuexi;


interface IUSB{     //接口标准USB
    public boolean check();           //检查方法
    public void work();               //工作方法
}
class computer{
    public void pligin(IUSB usb){
        if (usb.check()){
            usb.work();
        }else{
            System.out.println("设备不兼容！");
        }

    }
}
class keyboard implements IUSB{

    @Override
    public boolean check() {
        return true;
    }

    @Override
    public void work() {
        System.out.println("添加新设备成功，命名为键盘1号！");
    }
}
class mouse implements IUSB{

    @Override
    public boolean check() {
        return false;
    }

    @Override
    public void work() {
        System.out.println("添加新设备成功，命名为鼠标1号！");
    }
}
public class usbInterfaceTest {
    public static void main(String[] args){
        computer computer=new computer();
        computer.pligin(new keyboard());        //插入键盘
        computer.pligin(new mouse());           //插入鼠标
    }


}
